package jwr.hw;

import java.util.Scanner;

public class Cal {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a,b;
		String op;
		System.out.print("두 정수와연산자를 입력하시오>>");
		a = sc.nextInt();
		b = sc.nextInt();
		op = sc.next();
		if(op.equals("+")){
			Add cal = new Add();
			cal.setA(a);
			cal.setB(b);
			System.out.println(cal.toString());
		}else if(op.equals("-")){
			Sub cal = new Sub();
			cal.setA(a);
			cal.setB(b);
			System.out.println(cal.toString());
		}else if(op.equals("*")){
			Mul cal = new Mul();
			cal.setA(a);
			cal.setB(b);
			System.out.println(cal.toString());
		}else if(op.equals("/")){
			Div cal = new Div();
			cal.setA(a);
			cal.setB(b);
			System.out.println(cal.toString());
		}else{
			System.out.println("연산자를 제대로 입력해주세요.");
		}
	}

}



class Add extends CalExtends{
	public Add() {
		// TODO Auto-generated constructor stub
	}
	public int calculate(){
		return getA()+getB();
	}
	@Override
	public String toString() {
		result = getA()+" + "+getB()+" = "+calculate();
		return result;
	}
}

class Sub extends CalExtends{
	public Sub() {
		// TODO Auto-generated constructor stub
	}
	int calculate(){
		return getA()-getB();
	}
	@Override
	public String toString() {
		result = getA()+" - "+getB()+" = "+calculate();
		return result;
	}
}

class Mul extends CalExtends{
	public Mul() {
		// TODO Auto-generated constructor stub
	}
	int calculate(){
		return getA()*getB();
	}
	@Override
	public String toString() {
		result = getA()+" * "+getB()+" = "+calculate();
		return result;
	}
}

class Div extends CalExtends{
	public Div() {
		// TODO Auto-generated constructor stub
	}
	double calculate(){
		return (double)getA()/getB();
	}
	@Override
	public String toString() {
		result = getA()+" / "+getB()+" = "+calculate();
		return result;
	}
}
